#include "Mapping.h"
using namespace std;
Mapping::Mapping(void)
{
	m_ObsticleThreshold = 50;
}

Mapping::~Mapping(void)
{
}

int Mapping::getCols() {
	return myMap.getColums();
}

int Mapping::getRows() {
	return myMap.getRows();
}

int Mapping::getObsticleThreshold() {
	return m_ObsticleThreshold;
}

void Mapping::setObsticleThreshold(int inn) {
	if (inn > 10 && inn < 190) {
		m_ObsticleThreshold = inn;
	}
}

void Mapping::setCurrentLocation( Location inn ) {
	myMap.setCurrentLocation(inn);
}

void Mapping::setBaseLocation( Location inn ) {
	myMap.setBaseLocation(inn);
}

int Mapping::getTargetLocationsCounter( ) {
	return myMap.getTargetLocationsCounter( );
}

Location Mapping::getTargetLocation( int targetNr ) {
	return myMap.getTargetLocation(targetNr);
}

int Mapping::addTargetLocaton(Location inn) {
	return myMap.addTargetLocaton(inn);
}

void Mapping::changeTargetLocation(Location inn, int targetNr) {
	myMap.changeTargetLocation(inn,targetNr);
}

void Mapping::clearTargetLocations() {
	myMap.clearTargetLocations();
}

void Mapping::printMapOnScreen(int threshold) {
	myMap.printMapOnScreen(threshold);
}

bool* Mapping::getBooleanMap() {
	return myMap.getBooleanMap(m_ObsticleThreshold);
}

Location Mapping::getAgentLocation() {
	return myMap.getAgentLocation();
}

void Mapping::proccessSensorReading(double range, double bearing, int sensorType) {
	myMap.proccessSensorReading(range, bearing, sensorType);
}

void Mapping::Test(void) {
	Location base = Location();
	base.setX(12);
	base.setY(12);
	base.setB(0);

	Location curr = Location();
	curr.setX(8);
	curr.setY(10);
	curr.setB(90);

	Location t1 = Location();
	t1.setX(18);
	t1.setY(18);
	t1.setB(0);

	Location t2 = Location();
	t2.setX(15);
	t2.setY(3);
	t2.setB(0);

	myMap.setBaseLocation(base);
	myMap.setCurrentLocation(curr);
	myMap.addTargetLocaton(t1);
	myMap.addTargetLocaton(t2);
	
	double b1 = 180.00001 + curr.getB();
	double b2 = 280 + curr.getB();
	double b3 = 0 + curr.getB();

	myMap.proccessSensorReading(50.0, b1,0);
	myMap.proccessSensorReading(50.0, b2,0);
	myMap.proccessSensorReading(50.0, b3,0);
	myMap.printMapOnScreen(50);
	cout << endl << endl;

	myMap.proccessSensorReading(50.0, b1,0);
	myMap.proccessSensorReading(50.0, b2,0);
	myMap.proccessSensorReading(50.0, b3,0);
	myMap.printMapOnScreen(50);
	cout << endl << endl;
	
	myMap.proccessSensorReading(50.0, b1,0);
	myMap.proccessSensorReading(50.0, b2,0);
	myMap.proccessSensorReading(50.0, b3,0);
	myMap.printMapOnScreen(50);
	cout << endl << endl;
}